package com.xxx.client.controller;

import com.xxx.client.service.GrpcClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * gRPC client入口
 */
@RestController
public class GrpcClientController {

    @Autowired
    private GrpcClientService grpcClientService;

    /**
     * <a href="http://localhost:8088/sayHello?name=Bob">...</a>
     */
    @RequestMapping("/sayHello")
    public String sayHello(@RequestParam(defaultValue = "Alice") String name) {
        return grpcClientService.sayHello(name);
    }

    /**
     * <a href="http://localhost:8088/getAge?name=Bob">...</a>
     */
    @RequestMapping("/getAge")
    public String getAge(@RequestParam(defaultValue = "Alice") String name) {
        return grpcClientService.getAge(name);
    }

}
